﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;

namespace BUS
{
    public class NguoiDungBUS
    {
        protected NguoiDungDAO obj = new NguoiDungDAO();
        public List<NguoiDungDTO> GetALLNguoiDung()
        {
            return obj.GetAllNguoiDung();
        }
        public int Them(NguoiDungDTO nd)
        {
            string sql = string.Format("Insert into NguoiDung(TenNguoiDung,MatKhau,HoTen,Quyen) values('{0}','{1}',N'{2}','{3}')", nd.TenNguoiDung, nd.MatKhau,nd.HoTen,nd.Quyen);
            return obj.CapNhat(nd, sql);
        }
        public int Xoa(NguoiDungDTO nd)
        {
            string sql = "Delete from NguoiDung where TenNguoiDung=N'" + nd.TenNguoiDung+ "'";
            return obj.CapNhat(nd, sql);
        }
        public bool KTTenNguoiDung(string userName)
        {
            return obj.KTTenNguoiDung(userName);
        }
        public bool KTDoiMatKhau(string userName, string pass)
        {
            return obj.KTDoiMatKhau(userName, pass);
        }
        public int DoiMatKhau(NguoiDungDTO nd)
        {
            string sql = " Update NguoiDung set MatKhau=N'" + nd.MatKhau + "'";
            sql += " where TenNguoiDung=N'" + nd.TenNguoiDung + "'";
            return obj.CapNhat(nd, sql);
        }
    }
}
